#字母异位词分组
from typing import List
class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        from collections import defaultdict
        l=defaultdict(list)

        for i in strs:
            k="".join(sorted(i))
            l[k].append(i)

        return list(l.values())
strs=["eat", "tea", "tan", "ate", "nat", "bat"]
print(Solution().groupAnagrams(strs))
'''
输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
'''